
package com.jiu.ui;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class BaseFrame extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7391774538522487235L;
	
	@SuppressWarnings("static-access")
	public BaseFrame() {
		try {
			// 程序图标
			this.setIconImage(ImageIO.read(getClass().getResourceAsStream("image/fish.jpg")));
		} catch (IOException e1) {
		}
		// 退出监听事件
		this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);// 在窗口点X，什么都不做
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				exit(BaseFrame.this);
			}
			
		});
	}
	
	protected void exit(JFrame frame) {
		int value = JOptionPane.showConfirmDialog(frame, "您确认要退出吗？");
		if (value == JOptionPane.YES_OPTION) {
			frame.setVisible(false);
			System.exit(0);
		}
	}
}
